import { Component, Input } from '@angular/core';

@Component({
  selector: 'app-edit-period',
  templateUrl: './edit-period.component.html',
  styleUrls: ['./edit-period.component.scss']
})
export class EditPeriodComponent {
  @Input() data:any
  dateTypes = [
    {name:'月',value:true},
    {name:'日',value:false}
  ]
  dataType={name:'月',value:true}
  collectionPayments =[
    {name:'收',value:true},
    {name:'付',value:false}
  ]
  collectionPayment={name:'',value:null}
  form = {
    collectionPeriodName: "", // 字符串
    collectionPeriodClass: true, // true 或 false
    collectionPeriodDuration: 0, // 数字
    receiptOrPayment: null, // true收款 false付款
    note: "" // 备注
  };

  constructor() { }
  ngOnInit(): void {
    this.form = this.data.data;
    this.dataType = this.dateTypes.find(item=>item.value == this.form.collectionPeriodClass);
    this.collectionPayment = this.collectionPayments.find(item=>item.value == this.form.receiptOrPayment);
  }
  ngModelChange($event:any){
    this.form.collectionPeriodClass = this.dataType.value;
    this.form.receiptOrPayment = this.collectionPayment.value;

  }
}
